//
//  MyCollectionViewController.m
//  我的测试
//
//  Created by eliot on 16/8/5.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "MyCollectionViewController.h"
#import "MyCollectionViewCell.h"
#import "JPWaterflowLayout.h"
@interface MyCollectionViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>


@property (nonatomic, strong) UICollectionView *myCollectView;


@end

@implementation MyCollectionViewController


-(UICollectionView *)myCollectView {
    if (!_myCollectView) {

        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.minimumLineSpacing = 0;
        layout.minimumInteritemSpacing = 10;
//        layout.sectionInset = UIEdgeInsetsMake(0,0,0, 0);
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        _myCollectView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:[[JPWaterflowLayout alloc] init]];
        [_myCollectView registerNib:[UINib nibWithNibName:@"MyCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];
        [self.view addSubview:_myCollectView];
        _myCollectView.delegate = self;
        _myCollectView.dataSource = self;
    }
    return _myCollectView;

}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 20;

}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.myImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld", (long)indexPath.item]];
    return cell;
    
}




- (void)viewDidLoad {
    [super viewDidLoad];
    self.myCollectView.backgroundColor = [UIColor clearColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
